package org.example.footshoppingmaster.mapper;

import org.apache.ibatis.annotations.*;
import org.example.footshoppingmaster.pojo.DO.Address;

import java.util.List;

@Mapper
public interface AddressMapper {
    @Insert("INSERT INTO t_user_adress (userid,adname,adphone,adpca,addetail,adisdefault) VALUES (#{userid}, #{adname}, #{adphone}, #{adpca}, #{addetail},#{adisdefault});")
    boolean insertAddressAll(Address address);

    @Delete("delete from t_user_adress where id=#{id}")
    boolean delAddressById(Integer id);

    //通过用户id查询用户所有地址
    @Select("select * from t_user_adress where userid=#{userid}")
    List<Address> getAddressByUserId(Integer userid);

    //通过地址id对地址进行修改
    @Update("update t_user_adress set adname=#{adname}, adphone=#{adphone}, adpca=#{adpca}, addetail=#{addetail}, adisdefault=#{adisdefault} where id=#{id}")
    boolean UpdateAddressById(Address address);
}
